<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>分享爱车-车辆上架</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="汽车租赁系统">
</head>
<body>
<article class="page-container">

	<form class="form form-horizontal" id="form-car-putaway" >
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆估值：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" readonly="readonly" class="input-text" value="${(car.carprice)!""}" placeholder="车辆估值" id="carprice" name="carprice">
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车主姓名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" autocomplete="off" value="${(clientUser.name)!""}" placeholder="车主姓名" id="name" name="name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆类型</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" autocomplete="off" value="${(car.cartype)!""}" placeholder="车辆类型" id="cartype" name="cartype">
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆品牌：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${(car.carbrand)!""}" placeholder="车辆品牌" id="carbrand" name="carbrand">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>品牌型号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${(car.carbrandtype)!""}" placeholder="品牌型号" name="carbrandtype" id="carbrandtype">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>购买日期：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${(car.buydate)!""}" placeholder="购买日期" name="buydate" id="buydate">
		</div>
	</div>
	
	<hr/>
	
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>日租价格：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="日租价格" name="dayprice" id="dayprice">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆押金：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="车辆押金" name="tempmoney" id="tempmoney">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>违章押金：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="违章押金" name="rulemoney" id="rulemoney">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>基本保险：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="基本保险" name="basicinsure" id="basicinsure">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备编号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="设备编号" name="deviceid" id="deviceid">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>SIM卡号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="SIM卡号" name="simcard" id="simcard">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>超时费用：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="超时费用" name="timeoutmoney" id="timeoutmoney">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车主提成：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="车主提成" name="ownermoney" id="ownermoney">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>会员折扣：</label>
		<div class="formControls col-xs-8 col-sm-9">
			
			<input name="discount" id="discount" type="radio" value="1">启用</input>
		</div>
	</div>
		<br/>
	<div align="center" style="float:left height:60px">
	
			<input id="putaway" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;上架&nbsp;&nbsp;" />
			<input id="offcar" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;下架&nbsp;&nbsp;" />
            <input id="invalid" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;报废&nbsp;&nbsp;" />
	</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去--> 
<#include "include/_footer.html">
<!--/_footer /作为公共模版分离出去--> 

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">

    //向服务器提交车辆上架、下架或者报废   
	 var passCar = function(ispass){           
                $.ajax({
                    type: 'put',  
                    url: '/carupPutaway/${(car.carid)!''}', 
                    data:{
                            'dayprice': $("#dayprice").val()+'',
                            'tempmoney': $("#tempmoney").val(),
                            'rulemoney': $("#rulemoney").val(),
                            'basicinsure': $("#basicinsure").val(),
                            'deviceid': $("#deviceid").val(),
                            'simcard': $("#simcard").val(),
                            'timeoutmoney': $("#timeoutmoney").val(),
                            'ownermoney': $("#ownermoney").val(),
                            'discount': $("#discount").val(),                           
                            'carstate':ispass
                            },
                    success:function(data){ 
                        console.log('提交成功！');
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.$("#searchCars").click();
                        parent.layer.close(index);
                    }
                  });
             }
	
	
	//校验字段是否正确 
            function check(){ 
                /*关键在这儿，返回的是一个validate对象，这个对象有一个form方法，返回的是是否通过验证*/ 
                return $("#form-car-putaway").validate({ 
                            rules:{ 
                                simcard:{ 
                                    required:true ,
                                    isMobile:true                                  
                                },
                                dayprice:{ 
                                    required:true                                   
                                },
                                tempmoney:{ 
                                    required:true                                   
                                },
                                rulemoney:{ 
                                    required:true                                   
                                },
                                basicinsure:{ 
                                    required:true                                   
                                },
                                deviceid:{ 
                                    required:true                                   
                                },
                                timeoutmoney:{ 
                                    required:true                                   
                                },
                                ownermoney:{ 
                                    required:true                                   
                                }
                            }, 
                            messages:{ 
                                simcard:{ 
                                    required:"手机号不能为空",
                                    isMobile:"请输入正确手机号"   
                                },
                                dayprice:{ 
                                    required:"日租金额不能为空"                                   
                                },
                                tempmoney:{ 
                                    required:"车辆押金不能为空"                                  
                                },
                                rulemoney:{ 
                                    required:"违章押金不能为空"                                  
                                },
                                basicinsure:{ 
                                    required:"基本保险不能为空"                                  
                                },
                                deviceid:{ 
                                    required:"设备编号不能为空"                                 
                                },
                                timeoutmoney:{ 
                                    required:"超时费用不能为空"                                  
                                },
                                ownermoney:{ 
                                    required:"车主提成不能为空"                                  
                                }
                            }     
                        }); 
            } 
            
$(function(){
             //给上架按钮初始化事件//   if(!check().form()) return;  
             $("#putaway").click(function(){                    
                  if(!check().form()) return;
                  passCar(6); 
             }); 
             
             //给下架按钮初始化事件
             $("#offcar").click(function(){
                  if(!check().form()) return;
                  passCar(5); 
             });
                //给报废按钮初始化事件
             $("#invalid").click(function(){
                  if(!check().form()) return;
                  passCar(3); 
             });
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>